package edu.luc.cs.netkernel;

import com.ten60.netkernel.urii.IURAspect;
import com.ten60.netkernel.urii.aspect.StringAspect;
import org.ten60.netkernel.layer1.nkf.INKFConvenienceHelper;
import org.ten60.netkernel.layer1.nkf.INKFRequestReadOnly;
import org.ten60.netkernel.layer1.nkf.INKFResponse;
import org.ten60.netkernel.layer1.nkf.impl.NKFAccessorImpl;

/*
 *	This file is a slightly modified version of the NetKernel "HelloWorld" tutorial.
 *		(package: org.ten60.netkernel.tutorial)
 */
public class HelloNetKernel extends NKFAccessorImpl {
	
	// Call super class constructor and indicate that this
	// accessor is threadsafe and will only accept SOURCE requests
	public HelloNetKernel(){ 
		super(SAFE_FOR_CONCURRENT_USE, INKFRequestReadOnly.RQT_SOURCE);
	}

	public void processRequest(INKFConvenienceHelper context) throws Exception {
    
		// Create an immutable StringAspect wrapper for our text message
		IURAspect aspect = new StringAspect("Hello World. This is the JAVA representation of the HelloNetKernel resource.");

		// Create a response object containing the StringAspect
		INKFResponse response = context.createResponseFrom(aspect);
		
		// Set metadata indicating the MIME type of the response
		response.setMimeType("text/plain");

		// Set metadata indicating the response can be cached
		response.setCacheable();
	}
}
